package org.simple.controller;

import com.alibaba.fastjson.JSONObject;
import org.simple.constants.SmsContants;
import org.simple.service.ISmsService;
import org.simple.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/sms")
public class SmsController {
    @Autowired
    private ISmsService smsService;

    @PostMapping
    AjaxResult send(@RequestParam(value = "params",required = true) String params){

        System.out.println("params:"+params);
        Map<String,String> param= JSONObject.parseObject(params,Map.class);

        /*  封装参数 */
        param.put("Uid",SmsContants.SMS_UID );
        param.put("Key",SmsContants.SMS_KEY );

        return  smsService.sendSmsCode(param);
    }
}
